<template>
  <div class="page-container">
    <!-- 顶部标题 -->
    <div class="header-title">
      <h1>成都市市场监督管理局教育培训中心</h1>
    </div>
    <div class="register">
      <div class="register-card">
        <!-- Tab切换 -->
        <div class="register-tabs">
          <div
            :class="['tab-item', { active: activeTab === 'personal' }]"
            @click="activeTabSwith('enterprise')"
          >
            个人注册
          </div>
          <div
            :class="['tab-item', { active: activeTab === 'enterprise' }]"
            @click="activeTabSwith('personal')"
          >
            企业注册
          </div>
        </div>

        <!-- 个人注册表单 -->
        <el-form
          v-if="activeTab === 'personal'"
          ref="personalForm"
          :model="personalForm"
          :rules="personalRules"
          class="register-form"
        >
        <el-form-item prop="userName" label="账号">
              <el-input
                v-model="personalForm.userName"
                auto-complete="off"
                placeholder="请输入账号"
                maxlength="11"
              />
            </el-form-item>
          <el-form-item prop="phonenumber" label="手机号码">
            <el-input
              v-model="personalForm.phonenumber"
              auto-complete="off"
              placeholder="请输入手机号"
            />
          </el-form-item>
          <el-form-item prop="code" label="验证码">
            <el-input
              v-model="personalForm.code"
              auto-complete="off"
              placeholder="请输入验证码"
              style="width: 63%"
            />
            <div class="register-code">
              <el-button @click="sendPersonalCode" :disabled="personalExTime !== 60">{{personalExText}}</el-button>
            </div>
          </el-form-item>
          <el-form-item prop="password" label="密码">
            <el-input
              v-model="personalForm.password"
              type="password"
              auto-complete="off"
              placeholder="密码"
              @keyup.enter.native="handlePersonalRegister"
            >
              <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
            </el-input>
          </el-form-item>
          <el-form-item prop="confirmPassword" label="确认密码">
            <el-input
              v-model="personalForm.confirmPassword"
              type="password"
              auto-complete="off"
              placeholder="确认密码"
              @keyup.enter.native="handlePersonalRegister"
            >
              <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
            </el-input>
          </el-form-item>
          <el-form-item prop="nickName" label="姓名">
            <el-input
              v-model="personalForm.nickName"
              auto-complete="off"
              placeholder="请输入姓名"
            />
          </el-form-item>
          <el-form-item prop="idNumber" label="身份证号">
            <el-input
              v-model="personalForm.idNumber"
              auto-complete="off"
              placeholder="请输入身份证号"
            />
          </el-form-item>
          <!-- <el-form-item prop="administrativeArea" label="所属区域">
            <treeselect
            v-model="personalForm.administrativeArea"
            :options="personalRegionOptions"
            :normalizer="normalizer"
            placeholder="请选择所属区域"
            style="width: 100%"
            value-consists-of="BRANCH_PRIORITY"
            :valueFormat="getValueFormat()"
          >
            <div slot="value-label" slot-scope="{ node }">
              {{ getFullPathLabel(node) }}
            </div>
          </treeselect>
          </el-form-item>
          <el-form-item prop="position" label="专业技术职称">
            <treeselect
              v-model="personalForm.position"
              :options="positionOptions"
              :normalizer="normalizer"
              placeholder="请选择专业技术职称"
              style="width: 100%"
            />
          </el-form-item> -->
          <!-- 协议同意区域 -->
          <div class="protocol">
            <span
              :class="['protocol-checkbox', { active: personalForm.agreed }]"
              @click="personalForm.agreed = !personalForm.agreed"
            ></span>
            <span class="protocol-text">已阅并同意</span>
            <a target="_blank" class="protocol-link" href="隐私协议链接">《隐私协议》</a>
            <p v-show="showPersonalProtocolError" class="error-msg">
              <span class="msg-icon"></span>请先勾选协议
            </p>
          </div>
          <!-- 按钮组 -->
          <el-form-item class="custom-button-group">
            <div class="button-container">
              <div class="button-wrapper">
                <el-button
                  :loading="personalLoading"
                  size="medium"
                  type="primary"
                  class="action-button"
                  @click.native.prevent="handleBack"
                >
                  <span v-if="!personalLoading">返 回</span>
                  <span v-else>返 回 中...</span>
                </el-button>
                <el-button
                  :loading="personalLoading"
                  size="medium"
                  type="primary"
                  class="action-button"
                  @click.native.prevent="handlePersonalRegister"
                >
                  <span v-if="!personalLoading">注 册</span>
                  <span v-else>注 册 中...</span>
                </el-button>
              </div>
              <div class="link-wrapper">
                <router-link class="link-type" :to="'/login'">使用已有账户登录</router-link>
              </div>
            </div>
          </el-form-item>
        </el-form>

        <!-- 企业注册表单 -->
        <el-form
          v-if="activeTab === 'enterprise'"
          ref="enterpriseForm"
          :model="enterpriseForm"
          :rules="enterpriseRules"
          class="register-form"
        >
        <el-form-item prop="userName" label="账号">
            <el-input
              v-model="enterpriseForm.userName"
              auto-complete="off"
              placeholder="请输入账号"
            />
          </el-form-item>
          <el-form-item prop="nickName" label="联系人姓名">
            <el-input
              v-model="enterpriseForm.nickName"
              auto-complete="off"
              placeholder="请输入联系人姓名"
            />
          </el-form-item>
          <el-form-item prop="phonenumber" label="联系人手机">
            <el-input
              v-model="enterpriseForm.phonenumber"
              auto-complete="off"
              placeholder="请输入联系人手机号"
            />
          </el-form-item>
          <el-form-item prop="idNumber" label="联系人身份证号">
            <el-input
              v-model="enterpriseForm.idNumber"
              auto-complete="off"
              placeholder="请输入联系人身份证号"
            />
          </el-form-item>
          <el-form-item prop="code" label="验证码">
            <el-input
              v-model="enterpriseForm.code"
              auto-complete="off"
              placeholder="请输入验证码"
              style="width: 63%"
            />
            <div class="register-code">
              <el-button @click="sendEnterpriseCode" :disabled="enterpriseExTime !== 60">{{enterpriseExText}}</el-button>
            </div>
          </el-form-item>
          <el-form-item prop="password" label="密码">
            <el-input
              v-model="enterpriseForm.password"
              type="password"
              auto-complete="off"
              placeholder="密码"
              @keyup.enter.native="handleEnterpriseRegister"
            >
              <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
            </el-input>
          </el-form-item>
          <el-form-item prop="confirmPassword" label="确认密码">
            <el-input
              v-model="enterpriseForm.confirmPassword"
              type="password"
              auto-complete="off"
              placeholder="确认密码"
              @keyup.enter.native="handleEnterpriseRegister"
            >
              <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
            </el-input>
          </el-form-item>
          <el-form-item prop="unitName" label="单位名称">
            <el-input
              v-model="enterpriseForm.unitName"
              auto-complete="off"
              placeholder="请输入单位名称"
            />
          </el-form-item>
          <el-form-item prop="socialCreditCode" label="社会信用代码">
            <el-input
              v-model="enterpriseForm.socialCreditCode"
              auto-complete="off"
              placeholder="请输入社会信用代码"
            />
          </el-form-item>
          <!-- <el-form-item prop="administrativeArea" label="所属区域">
            <treeselect
              v-model="enterpriseForm.administrativeArea"
              :options="enterpriseRegionOptions"
              :normalizer="normalizer"
              placeholder="请选择所属区域"
              style="width: 100%"
              value-consists-of="BRANCH_PRIORITY"
              :valueFormat="getValueFormat()"
            >
              <div slot="value-label" slot-scope="{ node }">
                {{ getFullPathLabelEnterprise(node) }}
              </div>
            </treeselect>
            </el-form-item>
          <el-form-item prop="companyType" label="所在单位性质">
            <treeselect
              v-model="enterpriseForm.companyType"
              :options="enterpriseCompanyTypeOptions"
              :normalizer="normalizer"
              placeholder="请选择单位性质"
              style="width: 100%"
              value-consists-of="BRANCH_PRIORITY"
            />
          </el-form-item> -->
          <!-- 协议同意区域 -->
          <div class="protocol">
            <span
              :class="['protocol-checkbox', { active: enterpriseForm.agreed }]"
              @click="enterpriseForm.agreed = !enterpriseForm.agreed"
            ></span>
            <span class="protocol-text">已阅并同意</span>
            <a target="_blank" class="protocol-link" href="隐私协议链接">《隐私协议》</a>
            <a target="_blank" class="protocol-link" href="企业协议链接" style="margin-left: 5px;">《企业服务协议》</a>
            <p v-show="showEnterpriseProtocolError" class="error-msg">
              <span class="msg-icon"></span>请先勾选协议
            </p>
          </div>
          <!-- 按钮组 -->
          <el-form-item class="custom-button-group">
            <div class="button-container">
              <div class="button-wrapper">
                <el-button
                  :loading="enterpriseLoading"
                  size="medium"
                  type="primary"
                  class="action-button"
                  @click.native.prevent="handleBack"
                >
                  <span v-if="!enterpriseLoading">返 回</span>
                  <span v-else>返 回 中...</span>
                </el-button>
                <el-button
                  :loading="enterpriseLoading"
                  size="medium"
                  type="primary"
                  class="action-button"
                  @click.native.prevent="handleEnterpriseRegister"
                >
                  <span v-if="!enterpriseLoading">注 册</span>
                  <span v-else>注 册 中...</span>
                </el-button>
              </div>
              <div class="link-wrapper">
                <router-link class="link-type" :to="'/login'">使用已有账户登录</router-link>
              </div>
            </div>
          </el-form-item>
        </el-form>
      </div>

      <!--  底部  -->
      <div class="el-register-footer">
        <span></span>
      </div>
    </div>
  </div>
</template>

<script>
import { getPhoneCode, phoneRegister, sendCode, enterpriseRegister } from "@/api/login";
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'

export default {
  name: "phoneRegister",

  components: { Treeselect },
  data() {
    // 密码确认验证规则
    const equalToPassword1 = (rule, value, callback) => {
      if (this.personalForm.password !== value) {
        callback(new Error("两次输入的密码不一致"))
      } else {
        callback()
      }
    }
    const equalToPassword2 = (rule, value, callback) => {
      if (this.enterpriseForm.password !== value) {
        callback(new Error("两次输入的密码不一致"))
      } else {
        callback()
      }
    }

    return {
      title: process.env.VUE_APP_TITLE,
      activeTab: 'personal', // 当前激活的标签页

      // 个人注册相关数据
      personalForm: {
        uuid:"",
        nickName: "",
        phonenumber: "",
        code: "",
        password: "",
        confirmPassword: "",
        userName: "",
        idNumber: "",
        administrativeArea: null,
        position: null,
        agreed: false,
        regionLabel: '', // 存储完整路径
        documentType:"",
        exampleOne:"1"
      },
      positionOptions:[
        {
          id: 1,
          label: '高级',
          children: [
          ]
        },
        {
          id: 2,
          label: '中级',
          children: [
          ]
        }
      ],
      personalRegionOptions: [
        {
          id: 1,
          label: '华东区域',
          children: [
            { id: 11, label: '上海市' },
            { id: 12, label: '江苏省' },
            { id: 13, label: '浙江省' }
          ]
        },
        {
          id: 2,
          label: '华北区域',
          children: [
            { id: 21, label: '北京市' },
            { id: 22, label: '天津市' },
            { id: 23, label: '河北省' }
          ]
        }
      ],
      personalRules: {
        phonenumber: [{ required: true, trigger: "blur", message: "请输入手机号" }],
        code: [{ required: true, trigger: "blur", message: "请输入验证码" }],
        password: [
          { required: true, trigger: "blur", message: "请输入您的密码" },
          { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" },
          { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符：< > \" ' \\\ |", trigger: "blur" }
        ],
        confirmPassword: [
          { required: true, trigger: "blur", message: "请再次输入您的密码" },
          { required: true, validator: equalToPassword1, trigger: "blur" }
        ],
        userName: [{ required: true, trigger: "blur", message: "请输入账号" }],
        nickName: [{ required: true, trigger: "blur", message: "请输入姓名" }],
        idNumber: [{ required: true, trigger: "blur", message: "请输入身份证号" }],
        // administrativeArea: [{ required: true, trigger: "blur", message: "请选择所属区域" }],
        // position: [{ required: true, trigger: "blur", message: "请输入专业技术职称系列" }]
      },
      personalLoading: false,
      personalExText: '发送验证码',
      personalExTime: 60,
      personalTimerId: null,
      showPersonalProtocolError: false,

      // 企业注册相关数据
      enterpriseForm: {
        uuid:"",
        contacts: "",
        idNumber: "",
        nickName: "",
        userName: "",
        phonenumber: "",
        code: "",
        password: "",
        confirmPassword: "",
        unitName: "",
        socialCreditCode: "",
        administrativeArea: null,
        companyType: null,
        agreed: false,
        regionLabel: "", // 存储完整路径
        exampleOne:"2",
      },
      enterpriseRegionOptions: [
        {
          id: 1,
          label: '华东区域',
          children: [
            { id: 11, label: '上海市' },
            { id: 12, label: '江苏省' },
            { id: 13, label: '浙江省' }
          ]
        },
        {
          id: 2,
          label: '华北区域',
          children: [
            { id: 21, label: '北京市' },
            { id: 22, label: '天津市' },
            { id: 23, label: '河北省' }
          ]
        }
      ],
      enterpriseCompanyTypeOptions:[
        {
          id: 1,
          label: '高级',
          children: [
          ]
        },
        {
          id: 2,
          label: '中级',
          children: [
          ]
        }
      ],
      enterpriseRules: {
        userName: [{ required: true, trigger: "blur", message: "请输入账号" }],
        nickName: [{ required: true, trigger: "blur", message: "请输入法人代表姓名" }],
        idNumber: [{ required: true, trigger: "blur", message: "请输入法人身份证号" }],
        phonenumber: [{ required: true, trigger: "blur", message: "请输入法人手机号" }],
        code: [{ required: true, trigger: "blur", message: "请输入验证码" }],
        password: [
          { required: true, trigger: "blur", message: "请输入您的密码" },
          { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" },
          { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符：< > \" ' \\\ |", trigger: "blur" }
        ],
        confirmPassword: [
          { required: true, trigger: "blur", message: "请再次输入您的密码" },
          { required: true, validator: equalToPassword2, trigger: "blur" }
        ],
        unitName: [{ required: true, trigger: "blur", message: "请输入企业名称" }],
        socialCreditCode: [{ required: true, trigger: "blur", message: "请输入统一社会信用代码" }],
        // administrativeArea: [{ required: true, trigger: "blur", message: "请选择所属区域" }],
        // companyType: [{ required: true, trigger: "blur", message: "请输入单位性质" }]
      },
      enterpriseLoading: false,
      enterpriseExText: '发送验证码',
      enterpriseExTime: 60,
      enterpriseTimerId: null,
      showEnterpriseProtocolError: false,

      captchaEnabled: true,
      uuid:'',
    };
  },
  computed: {
  },
  methods: {
    // 递归查找节点路径:cite[2]
    findPath(options, targetId, path = []) {
      for (const option of options) {
        if (option.id === targetId) {
          return [...path, option.label];
        }

        if (option.children && option.children.length) {
          const result = this.findPath(option.children, targetId, [...path, option.label]);
          if (result) return result;
        }
      }
      return null;
    },

    // 获取完整路径标签
    getFullPathLabel(node) {
      if (!node || !node.id) return '';
      const path = this.findPath(this.personalRegionOptions, node.id);
      this.personalForm.regionLabel = path ? path.join(' / ') : '';
      return this.personalForm.regionLabel;
    },
    getFullPathLabelEnterprise(node) {
      if (!node || !node.id) return '';
      const path = this.findPath(this.enterpriseRegionOptions, node.id);
      this.enterpriseForm.regionLabel = path ? path.join(' / ') : '';
      return this.enterpriseForm.regionLabel;
    },

    // 获取值格式
    getValueFormat(node) {
      // 确保函数返回一个字符串
      if (node) {
        return node.id+''; // 自定义格式
      }
      return '';
    },
    normalizer(node) {
      return {
        id: node.id,
        label: node.label,
        children: node.children
      };
    },

    handleBack() {
      this.$router.push("/login")
    },

    // 生成UUID
    generateUuid() {
      this.uuid =  'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        const r = Math.random() * 16 | 0
        const v = c === 'x' ? r : (r & 0x3 | 0x8)
        return v.toString(16)
      })
      console.log('生成的UUID:', this.uuid)
    },
    // 个人注册相关方法
    sendPersonalCode() {
      const telCheck = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
      if (this.personalForm.phonenumber && telCheck.test(this.personalForm.phonenumber)) {
        this.personalCountDown();
        this.generateUuid();
        sendCode(this.personalForm.phonenumber, this.uuid).then(res => {
          if (res.code === 200) {
            this.$message.success("短信发送成功！");
          }
        })
      } else {
        this.$message.error("手机号输入不正确！");
      }
    },

    personalCountDown() {
      this.personalTimerId = setInterval(() => {
        if (this.personalExTime > 0) {
          this.personalExTime--;
        } else {
          clearInterval(this.personalTimerId);
          this.personalExTime = 60;
          this.personalExText = '发送验证码';
        }
      }, 1000);
    },

    handlePersonalRegister() {
      if (!this.personalForm.agreed) {
        this.showPersonalProtocolError = true;
        this.$message.error("请先同意隐私协议");
        return;
      }

      this.$refs.personalForm.validate(valid => {
        if (valid) {
          this.personalLoading = true;
          // if(this.personalForm.administrativeArea != ""  && this.personalForm.administrativeArea != null){
          //   const id =this.personalForm.administrativeArea.id
          //   this.personalForm.administrativeArea =id
          // }
          this.personalForm.uuid= this.uuid
          this.personalForm.documentType="1"
          this.personalForm.exampleOne="1"
          phoneRegister(this.personalForm).then(res => {
            const username = this.personalForm.phonenumber;
            this.$alert("<font color='red'>恭喜你，您的手机号 " + username + " 注册成功！</font>", '系统提示', {
              dangerouslyUseHTMLString: true,
              type: 'success'
            }).then(() => {
              this.$router.push("/login");
            }).catch(() => {});
          }).catch(() => {
            this.personalLoading = false;
          })
        }
      });
    },

    // 企业注册相关方法
    sendEnterpriseCode() {
      const telCheck = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
      if (this.enterpriseForm.phonenumber && telCheck.test(this.enterpriseForm.phonenumber)) {
        this.enterpriseCountDown();
        this.generateUuid();
        sendCode(this.enterpriseForm.phonenumber, this.uuid).then(res => {
          if (res.code === 200) {
            this.$message.success("短信发送成功！");
          }
        })
      } else {
        this.$message.error("手机号输入不正确！");
      }
    },

    enterpriseCountDown() {
      this.enterpriseTimerId = setInterval(() => {
        if (this.enterpriseExTime > 0) {
          this.enterpriseExTime--;
        } else {
          clearInterval(this.enterpriseTimerId);
          this.enterpriseExTime = 60;
          this.enterpriseExText = '发送验证码';
        }
      }, 1000);
    },

    handleEnterpriseRegister() {
      if (!this.enterpriseForm.agreed) {
        this.showEnterpriseProtocolError = true;
        this.$message.error("请先同意相关协议");
        return;
      }

      this.$refs.enterpriseForm.validate(valid => {
        if (valid) {
          this.enterpriseLoading = true;
          // if(this.enterpriseForm.administrativeArea != ""  && this.enterpriseForm.administrativeArea != null){
          //   const id =this.enterpriseForm.administrativeArea.id
          //   this.enterpriseForm.administrativeArea =id
          // }
          this.enterpriseForm.uuid= this.uuid
          this.enterpriseForm.documentType="2"
          this.enterpriseForm.exampleOne="2"
          phoneRegister(this.enterpriseForm).then(res => {
            const unitName = this.enterpriseForm.unitName;
            this.$alert("<font color='red'>恭喜你，企业 " + unitName + " 注册成功！</font>", '系统提示', {
              dangerouslyUseHTMLString: true,
              type: 'success'
            }).then(() => {
              this.$router.push("/login");
            }).catch(() => {});
          }).catch(() => {
            this.enterpriseLoading = false;
          })
        }
      });
    },
    activeTabSwith(val) {
      if (val !== "personal") {
        this.activeTab = "personal";
        // 重置表单验证
        this.$nextTick(()=>{
            this.$refs.personalForm.clearValidate();
        })
      }else{
        this.activeTab = "enterprise";
         this.$nextTick(()=>{
            this.$refs.enterpriseForm.clearValidate();
        })
      }
    },
  },
  watch: {
    personalExTime: {
      handler(val) {
        if (val > 0 && val < 60) {
          this.personalExText = val + "秒后重试";
        }
      }
    },
    enterpriseExTime: {
      handler(val) {
        if (val > 0 && val < 60) {
          this.enterpriseExText = val + "秒后重试";
        }
      }
    },
    'personalForm.agreed'() {
      if (this.personalForm.agreed) {
        this.showPersonalProtocolError = false;
      }
    },
    'enterpriseForm.agreed'() {
      if (this.enterpriseForm.agreed) {
        this.showEnterpriseProtocolError = false;
      }
    },
  },
  beforeDestroy() {
    // 清除定时器
    if (this.personalTimerId) clearInterval(this.personalTimerId);
    if (this.enterpriseTimerId) clearInterval(this.enterpriseTimerId);
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.page-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  background-color: #1f2d3d;
  background-image: url("../assets/images/login-background.jpg");
  background-size: cover;
  padding: 20px;
}

.header-title {
  width: 100%;
  text-align: center;
  margin-bottom: 30px;
  color: white;

  h1 {
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    color: #fff;
    margin: 0;
    padding: 15px 0;
    letter-spacing: 2px;
  }
}

.register {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  flex-direction: column;
}

.register-card {
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  width: 550px;
  overflow: hidden;
}

.register-tabs {
  display: flex;
  border-bottom: 1px solid #e6e6e6;

  .tab-item {
    flex: 1;
    text-align: center;
    padding: 15px 0;
    cursor: pointer;
    font-size: 16px;
    color: #606266;
    transition: all 0.3s;

    &.active {
      color: #409EFF;
      border-bottom: 2px solid #409EFF;
      font-weight: bold;
    }

    &:hover {
      color: #409EFF;
    }
  }
}

.title {
  margin: 20px auto 30px auto;
  text-align: center;
  color: #707070;
}

.register-form {
  padding: 25px 25px 5px 25px;

  .el-form-item {
    display: flex;
    align-items: center;

    .el-form-item__label {
      flex: 0 0 auto;
      width: 120px;
      text-align: right;
      padding-right: 12px;
    }

    .el-form-item__content {
      flex: 1;
      display: flex;
      align-items: center;
    }
  }

  .el-input {
    height: 38px;
    input {
      height: 38px;
    }
  }
  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}

.register-code {
  width: 33%;
  height: 38px;
  float: right;
  img {
    cursor: pointer;
    vertical-align: middle;
  }
}

.el-register-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}

.protocol {
  position: relative;
  margin-bottom: 15px;
  display: flex;
  align-items: center;

  .protocol-checkbox {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1px solid #dcdfe6;
    border-radius: 2px;
    cursor: pointer;
    margin-right: 8px;
    position: relative;

    &.active::after {
      content: "";
      position: absolute;
      left: 4px;
      top: 1px;
      width: 6px;
      height: 10px;
      border: solid #409EFF;
      border-width: 0 2px 2px 0;
      transform: rotate(45deg);
    }

    &.active {
      border-color: #409EFF;
      background-color: #409EFF;
    }
  }

  .protocol-text {
    font-size: 14px;
    color: #606266;
  }

  .protocol-link {
    color: #409EFF;
    text-decoration: none;
    margin-left: 5px;

    &:hover {
      text-decoration: underline;
    }
  }

  .error-msg {
    position: absolute;
    bottom: -20px;
    left: 0;
    color: #f56c6c;
    font-size: 12px;
    margin: 0;
    display: flex;
    align-items: center;

    .msg-icon {
      display: inline-block;
      width: 14px;
      height: 14px;
      background-color: #f56c6c;
      border-radius: 50%;
      color: white;
      text-align: center;
      line-height: 14px;
      margin-right: 5px;
      font-size: 12px;

      &::before {
        content: "!";
      }
    }
  }
}

.custom-button-group {
  .button-container {
    width: 100%;
    display: flex;
    flex-direction: column;

    .button-wrapper {
      display: flex;
      justify-content: center;
      gap: 15px;
      margin-bottom: 15px;
    }

    .link-wrapper {
      text-align: right;
      padding-top: 10px;
    }
  }

  .action-button {
    width: 120px;
  }
}
</style>
